package core.product.model;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Column;

import core.attribute.model.Attribute;
import core.attribute.model.AttributeSet;
import core.attribute.model.AttributeValue;

@Entity
@Table(name="productav")
public class ProductAv implements Serializable
{
	private static final long serialVersionUID = -8767337896773261247L;
	private Long uuid ;
	private Product product;
	private AttributeSet attributeSet ;
	private Attribute attribute;
	private Set<AttributeValue> attributeValues ;
	private String value ;
	
	@Id
	@GeneratedValue
	@Column(name="uuid")
	public Long getUuid() {
		return uuid;
	}
	public void setUuid(Long uuid) {
		this.uuid = uuid;
	}
	@ManyToOne(cascade = CascadeType.ALL)
	public Product getProduct() {
		return this.product;
	}
	public void setProduct(Product product) {
		this.product = product;
	}
	@ManyToOne(cascade = CascadeType.ALL)
	public AttributeSet getAttributeSet() {
		return attributeSet;
	}
	public void setAttributeSet(AttributeSet attributeSet) {
		this.attributeSet = attributeSet;
	}
	@ManyToOne(cascade = CascadeType.ALL)
	public Attribute getAttribute() {
		return attribute;
	}
	public void setAttribute(Attribute attribute) {
		this.attribute = attribute;
	}
	@ManyToMany(cascade = CascadeType.ALL , fetch = FetchType.EAGER)
	@JoinTable(name = "productav_attributevalue", joinColumns = {@JoinColumn(name ="productav_uuid") }, inverseJoinColumns = {@JoinColumn(name="attributevalue_uuid")})
	public Set<AttributeValue> getAttributeValues() {
		return attributeValues;
	}
	public void setAttributeValues(Set<AttributeValue> attributeValues) {
		this.attributeValues = attributeValues;
	}
	@Column(name="value")
	public String getValue() {
		return value;
	}
	public void setValue(String value) {
		this.value = value;
	}
}
